import java.util.*;
public class test {
    //蓝桥杯 兽之泪
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int N = in.nextInt();
        int[] x = new int[k];
        int[] y = new int[k];
        int n1 = N;
        int n2 = N;
        //能量(不挑战boss)
        long num1 = 0;
        //能量(挑战boss)
        long num2 = 0;
        PriorityQueue<List<Integer>> queue = new PriorityQueue<>(new Comparator<List<Integer>>() {
            @Override
            public int compare(List<Integer> o1, List<Integer> o2) {
                return o1.get(0).compareTo(o2.get(0));
            }
        });
        //此处不加入boss(因为boss存在<必须所有怪都打过才能挑战>的性质)
        for(int i = 0;i < k;i++) {
            List<Integer> arr = new ArrayList<>();
            x[i] = in.nextInt();
            y[i] = in.nextInt();
            arr.add(x[i]);
            arr.add(y[i]);
            //所有怪兽挑战一次所需能量
            num2 += x[i];
            n2--;
            if(i < k - 1) {
                queue.offer(arr);
            }
        }
        //未考虑boss
        while(n1 > 0){
            List<Integer> list = queue.poll();
            num1 += list.get(0);
            //(第一次挑战的怪兽,下次挑战所需能量从x变成y)
            if(list.get(0) < list.get(1)){
                list.set(0,list.get(1));
            }
            queue.offer(list);
            n1--;
        }
        //考虑boss
        PriorityQueue<List<Integer>> queue1 = new PriorityQueue<>(new Comparator<List<Integer>>() {
            @Override
            public int compare(List<Integer> o1, List<Integer> o2) {
                return o1.get(1).compareTo(o2.get(1));
            }
        });
        queue1 = queue;
        List<Integer> arr = new ArrayList<>();
        arr.add(x[k - 1]);
        arr.add(y[k - 1]);
        queue1.offer(arr);
        int min = queue1.peek().get(1);
        while(n2 > 0){
            num2 += min;
            n2--;
        }
        System.out.println(Math.min(num1,num2));
    }
    class Solution0 {
        //leetcode 1137.第N个泰波那契数
        public int tribonacci(int n) {
            int t0 = 0;
            int t1 = 1;
            int t2 = 1;
            if (n == 0) {
                return t0;
            }
            if (n == 1) {
                return t1;
            }
            if (n == 2) {
                return t2;
            }
            int number = 0;
            for (int i = n - 3; i >= 0; i--) {
                number = t0 + t1 + t2;
                t0 = t1;
                t1 = t2;
                t2 = number;
            }
            return number;
        }
        //leetcode 219.存在重复元素Ⅱ
        class Solution {
            public boolean containsNearbyDuplicate(int[] nums, int k) {
                HashMap<Integer, Integer> map = new HashMap<>();
                int length = nums.length;
                for (int i = 0; i < length; i++) {
                    if (!map.containsKey(nums[i])) {
                        map.put(nums[i], i);
                    } else {
                        if (i - map.get(nums[i]) <= k) {
                            return true;
                        } else {
                            map.put(nums[i], i);
                        }
                    }
                }
                return false;
            }
        }
    }
}
